﻿<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE;IE=11;IE=8,chrome=1" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>不合格特征维护</title>
    <link href="/InSiteWebApplication/Content/Easyui/themes/metro/easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/custom-easyui.css" rel="stylesheet" />
    <link href="/InSiteWebApplication/Content/Easyui/themes/icon.css" rel="stylesheet" />
    <style>
        .easyui-linkbutton{margin-left:20px;}
        table tr td{padding:0px 5px}
       #fm .l-btn-text{margin-top:3px}
    </style>
</head>
<body>
 <div class="panelSection">    
        <div class="easyui-panel " title="查询区域" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
           <form id="searchForm" method="post">
	    	<table>
	    		<tr class="divLabel">
                    <td>不合格特征:</td>
	    		</tr>
	    		<tr>
	    			<td><input  name="feature" class="easyui-textbox" style="width: 120px; height: 22px" id="feature"/></td>
                    <td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchData()">查询</a></td>
	    			<td><a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.searchReset()">重置</a></td>
	    		</tr>
	    	</table>
	    </form>
        </div> 
    </div>
    <div class="panelSection">
          <div class="easyui-panel " title="不合格特征维护" style="padding:3px;width:100%" data-options="closable:false,collapsible:true,minimizable:false,maximizable:false"> 
            <table id="UnqualifiedFeatureDefend" style="height:440px" data-options="rownumbers:true"></table>
            <div id="pp" style="float: right" class="easyui-pagination" data-options="   
                 layout:['first','prev','next','last','manual','info'],              
                    total: 0,
                    showPageList: false,
                    showPageInfo: false,
                    showRefresh: false,
                    afterPageText:'共&nbsp{pages}&nbsp页',
                     buttons:[{
                            iconCls:'',
                            text:'Go',
                            id:'pageGo'
                    }]
                ">
                    </div>
             <div style="margin-top:7px">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.appendRow('UnqualifiedFeatureDefend',{UnqualifiedFeatureID:'',UNQUALIFIEDFEATURENO:'',UNQUALIFIEDFEATURENAME:''})">新增</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.saveUnqualifiedFeature()">保存</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="page.deleteUnqualifiedFeature()">删除</a>
              <!--  <form id="fm" method="post" enctype="multipart/form-data" style="display:inline-block;margin-left:20px;">
                    <input class="easyui-filebox" id="fileUpload" name="fileUpload" style="width:68px;height: 24px;line-height: 24px;" data-options="buttonText:'导入模板',onChange:function(n,o){page.easyuiUpload(n,o);}"/>
                </form>-->
             </div>
             </div>
    </div>
     <!--信息提示区域-->
    <div id="statusMessage" style="font-size: 14px; height: 40px"></div>
</body>
</html>
<script src="/InSiteWebApplication/Scripts/json2.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/jquery.easyui.min.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Content/Easyui/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="/InSiteWebApplication/Scripts/CustomPageJs/CustomCommon.js" type="text/javascript"></script>
<script type="text/javascript">
    //创建人：longb
    //日期：2023-11-13
    //描述：不合格特征
    var page = {
        pagetotal: 0,
        pageSize: 20,
        pageNumber: 1,
        editIndex:undefined,
        team:null,
        workcenter:null,
        rootPath: getRootPath(), //网站根路径
        ajaxUrl: getRootPath() + "/Ashx/UnqualifiedHandler.ashx",
        //初始化页面
        init: function () {
            page.bind();
            customizedEasyuiPagination('pp'); //定制化分页
        },
        endEditing:function(id){
             if (page.editIndex == undefined){return true}   
             if ($('#'+id).datagrid('validateRow', page.editIndex)){
				var ed = $('#'+id).datagrid('getEditor', {index:page.editIndex});
				$('#'+id).datagrid('endEdit', page.editIndex);
				page.editIndex = undefined;
				return true;
			} else {
				return false;
			}
        },
        //页面事件绑定
        bind: function () {
            $('#UnqualifiedFeatureDefend').datagrid({
                checkOnSelect: true,
                selectOnCheck: false,
                singleSelect: true,
                rownumbers: true,
                columns: [[
                 {field:'ck',checkbox:true},
                 { field: 'UNQUALIFIEDFEATURENO', title: '顺序号', width: 100,align:'center' },
                 { field: 'UNQUALIFIEDFEATURENAME', title: '不合格特征', width: 300,editor:'textbox' },
		         { field: 'FACTORYNAME', title: '所属分厂', width: 150 }
                ]],
                onClickRow:function(index,row){
                    page.onClickRow(index,'UnqualifiedFeatureDefend');
                },
                onLoadSuccess: function (data) {
                    $('#pp').pagination('refresh', {	// 改变选项，并刷新分页栏信息
                        total: page.pagetotal,
                        pageSize: page.pageSize,
                        pageNumber: page.pageNumber
                    });
                    customizedEasyuiPagination('pp'); //定制化分页
                },
            });
            //分页事件
            $('#pp').pagination({
                onSelectPage: function (pageNumber, pageSize) {
                    customizedEasyuiPagination('pp'); //定制化分页
                    page.pageSize = pageSize; page.pageNumber = pageNumber;
                    page.getUnqualifiedFeature();
                }
            });
            //绑定分页go按钮
            $('#pageGo').on("click", function () {
                var pageNumber = $(this).parents('tr').find('.pagination-num').val();
                page.pageNumber = pageNumber;
                page.getUnqualifiedFeature();
            });
        },
        //查询
        searchData: function () {
            clearMessage();
            page.pageNumber = 1;
            page.getUnqualifiedFeature();
        },
        //查询重置
        searchReset: function () {
            $('#searchForm').form('clear');
            clearMessage();
        },
        getUnqualifiedFeature:function(){
            var param = {
                action: "getUnqualifiedFeature",
                pageSize: page.pageSize,
                pageNumber: page.pageNumber,
                feature: $('#feature').textbox('getValue')
            };
            page.post(param, function (res) {
                if (res.Result) {
                    page.pagetotal = res.RowCount;
                    $('#UnqualifiedFeatureDefend').datagrid('loadData', res.DBTable);
                }
            });
        },
        
        deleteUnqualifiedFeature:function(){
            var rows=$('#UnqualifiedFeatureDefend').datagrid('getChecked');
            if(rows.length==0){displayMessage('请选择至少一条信息再进行操作',false);return;}
            page.post({action:'deleteUnqualifiedFeature',data:JSON.stringify(rows)}, function (res) {
                 if(res.Result){
                    page.getUnqualifiedFeature();
                 }
                 displayMessage(res.Message, res.Result);
            })
        },
        
        ///保存
        saveUnqualifiedFeature:function(){
            $('#UnqualifiedFeatureDefend').datagrid('endEdit',page.editIndex);
            var rows= $('#UnqualifiedFeatureDefend').datagrid('getChanges');
            var param = {
                action: "saveUnqualifiedFeature",
                data:JSON.stringify(rows)
                }
           page.post(param, function (res) {
                if (res.Result) {
                    page.getUnqualifiedFeature();
                }
                displayMessage(res.Message, res.Result);
           });
        },
        appendRow:function(id,columns){
            $('#UnqualifiedFeatureDefend').datagrid('endEdit',page.editIndex);
            if (page.endEditing(id)){
				$('#'+id).datagrid('appendRow',columns);
				page.editIndex = $('#'+id).datagrid('getRows').length-1;
                $('#'+id).datagrid('getRows')[page.editIndex]['UNQUALIFIEDFEATURENO'] =page.editIndex+1;
				$('#'+id).datagrid('selectRow', page.editIndex).datagrid('beginEdit', page.editIndex);
			}
        },
        onClickRow:function(index,id){
            $('#UnqualifiedFeatureDefend').datagrid('endEdit',page.editIndex);
            page.editIndex=undefined;
            if (page.editIndex != index){
				if (page.endEditing(id)){
					$('#'+id).datagrid('selectRow', index).datagrid('beginEdit', index);
					page.editIndex = index;
				} else {
					$('#'+id).datagrid('selectRow', page.editIndex);
				}
			}
        },
        easyuiUpload: function (n,o) {
            if(o!=""){return;}
            if ($('#fileUpload').filebox('getValue') != "") {
                clearMessage();
                $('#fm').form('submit', {
                    url: page.ajaxUrl + "?action=ImportAssemWorkFlowTemplate",
                    onSubmit: function () {
                        return $(this).form('validate');
                    },
                    success: function (result) {
                        $('#fileUpload').filebox('clear');
                        var res = JSON.parse(result); 
                        if(res.Result){page.getTemlateData();}
                        displayMessage(res.Message, res.Result);
                    }
                });
            }
        },
        //post数据
        post: function (param, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                dataType: "json",
                beforeSend: function () {
                    $.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        },
        postasync: function (param, callback) {
            $.ajax({
                type: "Post",
                url: page.ajaxUrl,
                data: param,
                cashe: false,
                async: true,
                dataType: "json",
                beforeSend: function () {
                    //$.messager.progress({ text: '', msg: '处理中...' });
                },
                success: function (data) {
                    $.messager.progress('close');
                    callback(data);
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    $.messager.progress('close');
                    displayMessage(XMLHttpRequest.responseText, false);
                }
            });
        }
    }
    $(function () {
        page.init();
    });
</script>
